package com.learn.dubbo.core.systemenum;

public enum ExceptionEnum {
	
	/**
	 * 服务中没有这个方法
	 */
	NoMethodFound("The Service has no method found",100000),
	
	/**
	 * 连接数据库错误
	 */
	CommunicationsError("There is an error to connect the database ",100005),
	
	/**
	 * 处理对象为空错误
	 */
	NullPointerError("The object is null for an application to use ",100006),
	
	/**
	 * 参数为null
	 */
	ParametersIsNull("The parameters is null ",100007),
	
	/**
	 * 参数为Empty
	 */
	ParametersIsEmpty("The parameters is empty ",100008),
	
	/**
	 * 参数为Blank
	 */
	ParametersIsBlank("The parameters is blank ",100009),
	
	/**
	 * 未定义异常
	 */
	UndefinedError("The error is not undefined",100010),
	
	/**
	 * 字段重复[违反数据库唯一性]错误
	 */
	UniqueColumnError("The field has multiple value or The value is has already ",100014),
	
	/**
	 * 字段重复[违反数据库唯一性]错误
	 */
	DataFormatError("时间格式化错误",100016),
	
	/**
	 * 字段重复[违反数据库唯一性]错误
	 */
	SeverIsError("The server is error ",503),
	
	;
	
	//start 常量及方法

	private int code;
	private String value;
	
	ExceptionEnum(String value,int code) {
		this.code = code;
		this.value = value;
	}

	public int getCode() {
		return code;
	}

	public String getValue() {
		return value;
	}
	
	public static String getName(int code) {
        for (ExceptionEnum c : ExceptionEnum.values()) {
	        if (c.getCode() == code) {
	          return c.value;
	        }
        }
        return "程序错误！";
    }

}
